package task04;

import org.omg.CORBA.INTERNAL;

/**
 * @author yuanbinbing
 * 类由属性和方法组成：成员变量和成员方法
 * 人类：2个属性：姓名，年龄
 *       2个方法：吃饭，说话
 */
public class Person {
    private String name;
    private int age;
    /*构造方法*/
    Person(){
    }
    Person(String name){
      this.name = name;
    }
    Person(String name,int age){
       this.name = name;
       this.age = age;
    }

    /*封装方法*/
  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getAge() {
    return age;
  }

  public void setAge(int age) {
    this.age = age;
  }

  void eat(){
        System.out.println(name+"喜欢吃饭");
    }
    void speak(){
        System.out.println(name+"喜欢讲话");
    }
    void hobby(){
        System.out.println(name+"热爱打代码");
    }
}
